package main

import "fmt"

func testChannelClose(){
	jobs:=make(chan int,5)
	done:=make(chan bool)

	go func() {
		for {
			j,more := <-jobs
			if more {
				fmt.Println("receivedd Job",j)
			}else {
				fmt.Println("received all Job")
				done <- true
				return
			}
		}
	}()

	for j:= 1;j<=3;j++{
		jobs <-j
		fmt.Println("sent job", j)
	}
	close(jobs)
	fmt.Println("sent all jobs")
	<-done
}

func testChannelIter(){
	queue:= make(chan string,2)
	queue <-"one"
	queue <-"two"
	close(queue)
	for elem:=range queue {
		fmt.Println(elem)
	}
}